home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
163_01
/
atoi.c
< prev
next >
Wrap
Text File
|
1988-01-30
|
512b
|
16 lines
/*
** atoi -- convert signed decimal (ASCII) string to integer
*/
atoi(nptr) char *nptr; {
int atoi, sign;
atoi = sign = 0;
while(*nptr == '\t' || *nptr == ' ') nptr++;
if(*nptr == '-') {
sign = 1;
nptr++;
}
while(*nptr >= '0' && *nptr <= '9') atoi = (10 * atoi) + (*nptr++ - '0');
if(sign) return -atoi;
else return atoi;
}